<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background-color: red;
      }
      .box::after {
        content: "123";
        width: 50px;
        height: 50px;
      }
    </style>
    <!-- <div
      class="box"
      style="width: 100px; height: 100px; background-color: pink"
    ></div> -->
    <div class="box"></div>
    <script>
      // 获取行内
      //   var boxEle = document.querySelector(".box");
      //   document.onclick = function () {
      //     console.log(boxEle.style.height);
      //   };

      //   获取非行间
      var boxEle = document.querySelector(".box");
      document.onclick = function () {
        var res = getComputedStyle(boxEle, null)["background-color"];
        var res = getComputedStyle(boxEle, null)["width"];
        console.log(res);
      };
    </script>
  </body>
</html>
